home *** CD-ROM | disk | FTP | other *** search
- Path: nntp-xfer-2.csn.net!yuma!steffend
- From: steffend@lamar.colostate.edu (Dave Steffen)
- Newsgroups: comp.lang.c++
- Subject: Re: Newbie question on syntax of pointer to const
- Date: 29 Jan 1996 22:43:49 GMT
- Organization: Colorado State University, Fort Collins, CO 80523
- Message-ID: <4ejij5$3630@yuma.ACNS.ColoState.EDU>
- References: <4ej9eg$lq6@agate.berkeley.edu>
- NNTP-Posting-Host: glitch.physics.colostate.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- David C. Parsons (parsons@vouvray.CS.Berkeley.EDU) wrote:
- > In a declaration of a const reference or const pointer type, does it matter
- > in what the order the keyword const and the underlying type appear? That
- > is, are
-
- > (1) const double *pc; and
- > (2) double const *pc;
-
- > both acceptable syntax for type "pointer to constant double"? (My book only
- > describes (1), but my compiler accepts either.)
-
- I'm not sure what 2) should mean, which is probably your
- problem. The three possibilities I'm aware of are
-
- const double* pc; // pointer to constant double
- double* const pc; // const pointer to double
- const double* const pc; // const pointer to const double
-
- when you write "double const *", AFAIK that doesn't fit in with the syntax
- of the language. I _think_ that your compiler is (wrongly) accepting
- 2) as meaning one of the above; but which one is anybody's guess.
-
- However, I'm not sure this is your problem (although it _is_
- important to get right ;-)
-
- > The reason I ask is because I'm getting the following error from the linker:
-
- > /bin/ld: Unsatisfied symbols:
- > operator<<(ostream &, Matrix<double> const &)(code)
- > Matrix<double>::Matrix(Matrix<double> const &)(code)
-
- > even though I have definitions like these:
-
- > template <class Type>
- > ostream& operator <<( ostream& os, const Matrix<Type>& m )
- > { ... }
-
- > template <class Type>
- > Matrix<Type>::Matrix( const Matrix<Type> &m )
- > { ... }
-
- > Are the function prototypes in the error message different from these in
- > some way I'm overlooking?
-
- These look fine at first glance, the problem is probably a
- template issue with your compiler. Most compilers are still iffy
- regarding template issues; GNU G++ 2.7.0 essentially requires the
- _definitions_ of your templates in the _header_ files. My older
- version of Borland (3.1 I think) requires the same thing.
-
- So check the docs on your compiler carefully and make sure
- it's finding the template definitions where it wants them to be.
-
- /\
- \/
-
- Dave Steffen No, his mind is not for rent
- Dept. of Physics To any God or Government
- Colorado State University Always hopeful, yet discontent
- steffend@lamar.colostate edu He knows changes aren't permanent-
- But change is...
- "Speak softly...
- ... and carry a black belt!" -Neal Peart / RUSH
- -----------------------------------------------------------------------
-
-
-
-